﻿@model CombinedSearchViewModel

@{ ViewBag.Title = "Combined search"; }

<section>
    <div class="grid_12 clearfix">
        <br />
        <h3>Search for a team, person, competition, country or venue:</h3>
        
        @Html.Partial("AutoComplete/_Combined", "combinedAutoComplete")
        <br /><br />
    </div>

    <div class="grid_12 clearfix">
        
        @foreach (var item in Model.TeamVersions)
        {
            @Html.DisplayFor(m => item)
        }

        @foreach (var item in Model.People)
        {
            @Html.DisplayFor(m => item)
        }

        @foreach (var item in Model.Competitions)
        {
            @Html.DisplayFor(m => item)
        }

        @foreach (var item in Model.Countries)
        {
            @Html.DisplayFor(m => item)
        }

        @foreach (var item in Model.Venues)
        {
            @Html.DisplayFor(m => item)
        }
    </div>
</section>

<script type="text/javascript">
    function combinedAutoCompleteAdditionalData() {
        return { text: $("#combinedAutoComplete").val() };
    }

    function combinedAutoComplete_onChange() {
        var url = '@Url.Action("Index", new { id = "__REPLACE__" })';
        window.location.href = url.replace('__REPLACE__', $("#combinedAutoComplete").val());
    }
</script>